load("//bazel:tachyon_cc.bzl", "tachyon_cc_library", "tachyon_cc_unittest")

package(default_visibility = ["//visibility:public"])

tachyon_cc_library(
    name = "circuit",
    hdrs = ["circuit.h"],
    deps = [":constraint_system"],
)

tachyon_cc_library(
    name = "constraint_matrices",
    hdrs = ["constraint_matrices.h"],
    deps = [":matrix"],
)

tachyon_cc_library(
    name = "constraint_system",
    hdrs = ["constraint_system.h"],
    deps = [
        ":constraint_matrices",
        ":linear_combination",
        ":optimization_goal",
        ":synthesis_mode",
        "//tachyon/base/containers:container_util",
        "//tachyon/base/functional:callback",
        "@com_google_absl//absl/container:btree",
        "@com_google_googletest//:gtest_prod",
    ],
)

tachyon_cc_library(
    name = "linear_combination",
    hdrs = ["linear_combination.h"],
    deps = [
        ":term",
        "//tachyon/base:sort",
        "//tachyon/base/containers:container_util",
        "//tachyon/base/ranges:algorithm",
        "@com_google_googletest//:gtest_prod",
    ],
)

tachyon_cc_library(
    name = "matrix",
    hdrs = ["matrix.h"],
    deps = [
        "//tachyon/base/containers:container_util",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_library(
    name = "optimization_goal",
    hdrs = ["optimization_goal.h"],
)

tachyon_cc_library(
    name = "qap_instance_map_result",
    hdrs = ["qap_instance_map_result.h"],
)

tachyon_cc_library(
    name = "qap_witness_map_result",
    hdrs = ["qap_witness_map_result.h"],
)

tachyon_cc_library(
    name = "quadratic_arithmetic_program",
    hdrs = ["quadratic_arithmetic_program.h"],
    deps = [
        ":constraint_system",
        ":qap_instance_map_result",
        ":qap_witness_map_result",
        "//tachyon/base:optional",
        "//tachyon/base:parallelize",
        "//tachyon/base:profiler",
    ],
)

tachyon_cc_library(
    name = "synthesis_mode",
    hdrs = ["synthesis_mode.h"],
)

tachyon_cc_library(
    name = "term",
    hdrs = ["term.h"],
    deps = [":variable"],
)

tachyon_cc_library(
    name = "variable",
    srcs = ["variable.cc"],
    hdrs = ["variable.h"],
    deps = [
        "//tachyon:export",
        "//tachyon/base:logging",
        "@com_google_absl//absl/strings",
    ],
)

tachyon_cc_unittest(
    name = "r1cs_unittests",
    srcs = [
        "constraint_system_unittest.cc",
        "linear_combination_unittest.cc",
        "variable_unittest.cc",
    ],
    deps = [
        ":constraint_system",
        "//tachyon/base:random",
        "//tachyon/math/finite_fields/test:finite_field_test",
        "//tachyon/math/finite_fields/test:gf7",
    ],
)
